package com.ktgj.train.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.train.domain.TrainPayRefundrecord;
import com.ktgj.train.service.ITrainPayRefundrecordService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 支付退款记录Controller
 * 
 * @author ruoyi
 * @date 2021-11-29
 */
@ControllerAdvice
@RestController
@RequestMapping("/payRefundrecord")
public class TrainPayRefundrecordController extends BaseController
{
    @Autowired
    private ITrainPayRefundrecordService trainPayRefundrecordService;

    /**
     * 查询支付退款记录列表
     */
    @PreAuthorize(hasPermi = "train:refundrecord:list")
    @GetMapping("/list")
    public TableDataInfo list(TrainPayRefundrecord trainPayRefundrecord)
    {
        startPage();
        List<TrainPayRefundrecord> list = trainPayRefundrecordService.selectTrainPayRefundrecordList(trainPayRefundrecord);
        return getDataTable(list);
    }

    /**
     * 导出支付退款记录列表
     */
    @PreAuthorize(hasPermi = "train:refundrecord:export")
    @Log(title = "支付退款记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TrainPayRefundrecord trainPayRefundrecord) throws IOException
    {
        List<TrainPayRefundrecord> list = trainPayRefundrecordService.selectTrainPayRefundrecordList(trainPayRefundrecord);
        ExcelUtil<TrainPayRefundrecord> util = new ExcelUtil<TrainPayRefundrecord>(TrainPayRefundrecord.class);
        util.exportExcel(response, list, "支付退款记录数据");
    }

    /**
     * 获取支付退款记录详细信息
     */
    @PreAuthorize(hasPermi = "train:refundrecord:query")
    @GetMapping(value = "/{refundrecordid}")
    public AjaxResult getInfo(@PathVariable("refundrecordid") Long refundrecordid)
    {
        return AjaxResult.success(trainPayRefundrecordService.selectTrainPayRefundrecordById(refundrecordid));
    }

    /**
     * 新增支付退款记录
     */
    @PreAuthorize(hasPermi = "train:refundrecord:add")
    @Log(title = "支付退款记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TrainPayRefundrecord trainPayRefundrecord)
    {
        return toAjax(trainPayRefundrecordService.insertTrainPayRefundrecord(trainPayRefundrecord));
    }

    /**
     * 修改支付退款记录
     */
    @PreAuthorize(hasPermi = "train:refundrecord:edit")
    @Log(title = "支付退款记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TrainPayRefundrecord trainPayRefundrecord)
    {
        return toAjax(trainPayRefundrecordService.updateTrainPayRefundrecord(trainPayRefundrecord));
    }

    /**
     * 删除支付退款记录
     */
    @PreAuthorize(hasPermi = "train:refundrecord:remove")
    @Log(title = "支付退款记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{refundrecordids}")
    public AjaxResult remove(@PathVariable Long[] refundrecordids)
    {
        return toAjax(trainPayRefundrecordService.deleteTrainPayRefundrecordByIds(refundrecordids));
    }
}
